import 'package:flutter/material.dart';

class  MyBottomNavigationBar extends StatefulWidget{
  @override
  MyBottomNavigationBarState createState() {
    // TODO: implement createState
    return MyBottomNavigationBarState();
  }

}
class MyBottomNavigationBarState extends State<MyBottomNavigationBar>{
  List<Widget> list=[
    Center(child: Text("首页"),),
    Center(child: Text("我的"),),

  ];
  var _currentIndex=0;
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text("底部导航栏"),
      ),
      body: list[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        items: [
          BottomNavigationBarItem(activeIcon: Icon(Icons.home),icon: Icon(Icons.home,color: Colors.grey,),title: Text("首页")),
          BottomNavigationBarItem(activeIcon: Icon(Icons.people),icon: Icon(Icons.people,color: Colors.grey,),title: Text("我的")),
        ],
        currentIndex: _currentIndex,
        onTap: (int index){
          setState(() {
            _currentIndex=index;
          });
        },
      ),
    );
  }
}